#include <stdlib.h>
#include <stdio.h>
#include <sqlite3.h>

int main(){
  sqlite3 *db;
  char *errMsg;
  char sql[100];
  
  int res = sqlite3_open ("/home/wan/mydb", &db);
  if(res){
    fprintf (stderr, "打开数据库错误：%s\n",sqlite3_errmsg(db));
    exit(0);
  }
  sprintf(sql,"delete from student where id=%d",3);
  printf("sql=%s\n",sql);
  res = sqlite3_exec (db, sql, NULL, NULL, &errMsg);
  if(res!=SQLITE_OK){
    fprintf (stderr, "删除有错误:%s\n",errMsg);
    sqlite3_free (errMsg);
  }
  printf("删除成功!\n");
  sqlite3_close(db);
  return 0;
}
